# encoding:utf-8
import hashlib


class State(object):
    def __init__(self, apk_name, screen_shot):
        self.belong_apk = apk_name
        self.screen_shot = screen_shot
        self.time_name = screen_shot[screen_shot.rfind('\\') + 1:-4]
        self.md5_name = self.CalcMD5(screen_shot)
        self.position_dict = {}

    def CalcMD5(self, filepath):
        with open(filepath, 'rb') as f:
            md5obj = hashlib.md5()
            md5obj.update(f.read())
            hash = md5obj.hexdigest()
            # print(hash)
            return hash

    def fill_position_dict(self, position_dict):
        self.position_dict = position_dict
